package com.share.example.selenium.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.share.example.selenium.mapper.UserMapper;
import com.share.example.selenium.model.db.User;
import com.share.example.selenium.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * jenkins接口配置变  服务实现类
 * </p>
 *
 * @author author
 * @since 2023-09-28
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    private Map<String, List<User>> userMap = new HashMap();

    @Autowired
    private UserMapper userMapper;


    @Override
    public List<User> listByBizCode(String bizCode) {
        return userMap.get(bizCode);
    }

    @Override
    public Map<String, List<User>> initCalendarMap() {
        List<User> tmpList = userMapper.selectList(null);
        Map<String, List<User>> tmpMap = new HashMap();
        for (User item : tmpList) {
            String bizCode = item.getBizCode();
            List<User> bizList = tmpMap.get(bizCode);
            if (bizList == null) {
                bizList = new LinkedList<User>();
                tmpMap.put(bizCode, bizList);
            }

            bizList.add(item);
        }

        if (tmpMap.size() > 0) {
            this.userMap = tmpMap;
        }

        return tmpMap;
    }

}
